package com.kevin.proxy.dynamicProxy.jdkProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class ProxyO implements InvocationHandler {
    private Object object;

    public ProxyO(Object object) {
        this.object = object;
    }

    public ProxyO() {
    }

    public Object getProxyO(Object o){
        this.object = o;
        return Proxy.newProxyInstance(object.getClass().getClassLoader(),object.getClass().getInterfaces(),this);
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("男人");
        method.invoke(object,args);
        System.out.println("女人");
        return null;
    }
}
